import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "DBshop0011_添加商品流程"
# "1.打开后台,商品管理,管理商品
firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
DBshopEnterMenu2(firefox,"商品管理","管理商品")
# 2.点击添加商品按钮，商品名称填写“苹果XR”,本店价格“7999”，商品类型“虚拟商品”。
firefox.find_element_by_link_text('添加商品').click()
firefox.find_element_by_id('goods_name').send_keys('苹果XR')
firefox.find_element_by_id('goods_shop_price').send_keys('7999')
firefox.find_element_by_xpath('//option[text()="虚拟商品"]').click()
# 2.点击“保存商品”按钮，后台保存成功添加的商品。"
firefox.find_element_by_xpath('//button[@class="btn btn-small btn-primary" and @ type="submit"]').click()
#断言
firefox.find_element_by_xpath('(//input[@class="span11"])[1]').send_keys('苹果XR')
firefox.find_element_by_xpath('//button').click()
a=firefox.find_element_by_xpath('//td[contains(.,"苹果XR")]').text
print(a)
try:
    firefox.find_element_by_xpath('//td[contains(.,"苹果XR")]').is_displayed()
    writeLog("%s 测试成功" % testCase)
    getPhoto(firefox)
except:
    writeLog("%s 测试失败" % testCase)